﻿using AutoMapper;
using LpbPrj.Client.Patients;
using LpbPrj.Client.Patients.Dtos;

namespace LpbPrj.Client.Patients.Mapper
{
    internal static class PatientMapper
    {
        public static void CreateMappings(IMapperConfigurationExpression mapperConfig)
        {
            mapperConfig.CreateMap<PatientEditDto, Patient>();
            //定义单向映射
            mapperConfig.CreateMap<Patient, PatientEditDto>();

            mapperConfig.CreateMap<PatientListDto, Patient>();
            mapperConfig.CreateMap<Patient, PatientListDto>()
                //.ForMember(dto => dto.CreationDate, map => map.MapFrom(m => m.CreationTime.ToString("yyyy/MM/dd")))
                //.ForMember(dto => dto.CreationDateTime, map => map.MapFrom(m => m.CreationTime.ToString("yyyy/MM/dd HH:mm:ss")))
                //.ForMember(dto => dto.PatientBirthdayStr, map => map.MapFrom(m => m.PatientBirthday.HasValue ? ((DateTime)m.PatientBirthday).ToString("yyyy/MM/dd") : string.Empty))
                //.ForMember(dto => dto.PatientAge, map => map.MapFrom(m => m.PatientBirthday.HasValue ? DateTime2Timespanstr((DateTime)m.PatientBirthday, DateTime.Now) : string.Empty))
                //.ForMember(dto => dto.PatientSexStr, map => map.MapFrom(m => GetSexName(m.PatientSex)))
                ;


        }
    }
}